package com.excesys.exsecs.access.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.excesys.exsecs.access.dto.AccessFloorDTO;
import com.excesys.exsecs.access.entity.AccessFloor;
import com.excesys.exsecs.access.vo.AccessFloorVO;
import com.excesys.exsecs.common.data.datascope.ExsecsBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AccessFloorMapper extends ExsecsBaseMapper<AccessFloor> {

    /**
     * 按条件联表查询,使用 Wrapper自定义SQL
     */
    @Select("select bamf.*,bamb.buildings_cn as buildings_name "
            + "from access_floor bamf LEFT JOIN access_buildings bamb " + "on bamf.floor_pid=bamb.buildings_id "
            + "${ew.customSqlSegment}  ")
    IPage<AccessFloorVO> getBamSFloorVosPage(IPage<Object> page,
                                             @Param(Constants.WRAPPER) QueryWrapper<AccessFloorDTO> query);

    /**
     * 按条件联表查询,使用 Wrapper自定义SQL
     */
    @Select("select bamf.*,bamb.buildings_cn as buildings_name "
            + "from access_floor bamf LEFT JOIN access_buildings bamb " + "on bamf.floor_pid=bamb.buildings_id "
            + "${ew.customSqlSegment}  ")
    List<AccessFloorVO> getBamSFloorVos(@Param(Constants.WRAPPER) QueryWrapper<AccessFloorDTO> query);
}